package com.wkr.order.service.impl;

import com.wkr.order.dao.TrainOrderDao;
import com.wkr.order.entity.TrainOrderEntity;
import com.wkr.order.service.IOrderService;
import io.seata.core.context.RootContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.time.LocalDateTime;

@Service
@Slf4j
public class TrainOrderServiceImpl implements IOrderService {

    @Resource
    private TrainOrderDao trainOrderDao;

    @Override
    @Transactional
    public void create() {
        log.info("XID: "+ RootContext.getXID());
        TrainOrderEntity data = new TrainOrderEntity();
        data.setCreateTime(LocalDateTime.now());
        data.setUpdateTime(LocalDateTime.now());
        trainOrderDao.save(data);
    }
}
